/*
 * Copyright (C) 2013 The original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy
 * of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.zapta.apps.maniana.editors;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.zapta.apps.maniana.R;
import com.zapta.apps.maniana.annotations.MainActivityScope;
import com.zapta.apps.maniana.editors.EditRepeat;

/**
 *
 * @author Elliott Mitchell
 */
@MainActivityScope
public class EditRepeatYear extends EditRepeatMonth {

	@Override
	public void setArguments(Bundle bundle) {
		super.setArguments(bundle);

		int period=bundle.getByte("item_repeat_months", (byte)0);
		period=((period&0xFFFF)+7)/12;
		if(period<=0) period=1;
		period=period*12-1;
		bundle.putByte("item_repeat_months", (byte)period);
	}

	@Override
	int getRepeatHeaderId() {
		return R.string.editor_repeat_year_header;
	}

	@Override
	int getRepeatPeriod() {
		return (super.getRepeatPeriod()+6)/12;
	}

	@Override
	int setRepeatPeriod(int count) {
		if(count>0x100/12) count=0x100/12; // max value
		super.setRepeatPeriod(count*12);
		return count;
	}
}

